<!--
 * @Author: xiaodong 565071984@qq.com
 * @Date: 2022-05-09 21:35:06
 * @LastEditors: xiaodong 565071984@qq.com
 * @LastEditTime: 2022-05-09 21:49:40
 * @FilePath: /ywl/Volumes/ExtremeSSD/项目/小票/src/views/systemManagement/roleManagement/components/UserManagementEdit.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <el-dialog
    :title="title"
    :visible.sync="dialogFormVisible"
    width="500px"
    @close="close"
  >
    <el-form ref="form" :model="form" :rules="rules" label-width="80px">
      <el-form-item label="玩法名称" prop="name">
        <el-input v-model="form.name" autocomplete="off"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="close">取 消</el-button>
      <el-button type="primary" @click="save">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { doEdit } from '@/api/roleManagement'
import { addScene } from '@/api/business.js'
export default {
  name: 'RoleManagementEdit',
  data() {
    return {
      form: {
        id: '',
      },
      rules: {
        name: [{ required: true, trigger: 'blur', message: 'input name ' }],
      },
      title: '',
      dialogFormVisible: false,
    }
  },
  created() {},
  methods: {
    showEdit(row) {
      if (!row) {
        this.title = '新增玩法'
      } else {
        this.title = '编辑'
        this.form = Object.assign({}, row)
      }
      this.dialogFormVisible = true
    },
    close() {
      this.$refs['form'].resetFields()
      this.form = this.$options.data().form
      this.dialogFormVisible = false
    },
    save() {
      this.$refs['form'].validate(async (valid) => {
        if (valid) {
          const { data } = await addScene(this.form)
          if (data.code == 0) {
            this.$baseMessage(msg, 'success')
            this.$emit('fetch-data')
            this.close()
          } else {
            this.$baseMessage(msg, 'warm')
          }
        } else {
          return false
        }
      })
    },
  },
}
</script>
